import {Schema, model, Document, Model} from 'mongoose';

interface EcpmDocument extends Document {
    cost: number;          // 广告收入，单位 1/100000 元
    event_name: string;    // 广告计费事件名
    event_time: number;      // 广告计费事件发生时间
    open_id: string;       // 用户 openID
    id: number;            // 记录唯一标识
    appid?: string
}

const EcpmSchema: Schema = new Schema<EcpmDocument>({
    cost: {type: Number, required: true},
    event_name: {type: String, required: true},
    event_time: {type: Number, required: true},
    open_id: {type: String, required: true},
    id: {type: Number, required: true, unique: true},
    appid: String
});

export const EcpmModel: Model<EcpmDocument> = model<EcpmDocument>('ecpms', EcpmSchema)